package com.lagou.minicat.core;

import org.dom4j.Document;
import org.dom4j.io.SAXReader;

import java.io.InputStream;

public class Server {

    private Document serverConfigDoc;
    private Service service;

    public void init() throws Exception {
        // 读取server.xml
        InputStream resourceAsStream = this.getClass().getClassLoader().getResourceAsStream("server.xml");
        SAXReader saxReader = new SAXReader();
        serverConfigDoc = saxReader.read(resourceAsStream);

        // 初始化Service
        Service service = new Service();
        service.init(serverConfigDoc);
        this.service = service;
    }

    public Service getService() {
        return service;
    }

    public void setService(Service service) {
        this.service = service;
    }
}
